package com.isaiah.oa.controller;

import com.isaiah.oa.pojo.User;
import com.isaiah.oa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by 孙圣征 on 2017/12/2.
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/listUser")
    public String listUser(Model model){
        List<User> userList = userService.getUsers();
        model.addAttribute("userList", userList);
        return "user/listUser";
    }
    @RequestMapping("/addUserPro")
    public String addUserPro(User user){
        userService.addUser(user);
        return "redirect:/user/listUser";
    }
}
